package br.com.merks.model;

import java.math.BigDecimal;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import br.com.yx.vraptor.security.SecurityUser;
@NamedQueries({
	@NamedQuery(name="user.findAll",query="SELECT x FROM br.com.merks.model.User x WHERE x.emailValid = 1"),
	@NamedQuery(name="user.login",query="SELECT x FROM br.com.merks.model.User x WHERE x.login = :login AND x.emailValid = 1"),
	@NamedQuery(name="user.token",query="SELECT x FROM br.com.merks.model.User x WHERE x.emailValidToken = :token")
})
@Entity
public class User implements SecurityUser {
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;
	private String login;
	private String name;


	private String email;
	private Integer ageYear;
	private Integer ageMonth;
	private Integer emailValid; //0false 1 true
	private String emailValidToken;
	private Integer ageDay;
	private Integer gender; //1 = Man;0 = Woman
	private String password;
	private String password2;
	
	private String city;
	private String state;
	private String country;
	
	

	private String twitter;
	private String orkut;
	private String facebook;
	private String blog;
	
	private BigDecimal merks;
	
	private String roles;

	public Integer getEmailValid() {
		return emailValid;
	}

	public String getRoles() {
		return roles;
	}

	public void setRoles(String roles) {
		this.roles = roles;
	}

	public void setEmailValid(Integer emailValid) {
		this.emailValid = emailValid;
	}

	public Integer getGender() {
		return gender;
	}

	public void setGender(Integer gender) {
		this.gender = gender;
	}
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}


	public Integer getAgeYear() {
		return ageYear;
	}

	public void setAgeYear(Integer ageYear) {
		this.ageYear = ageYear;
	}

	public Integer getAgeMonth() {
		return ageMonth;
	}

	public void setAgeMonth(Integer ageMonth) {
		this.ageMonth = ageMonth;
	}

	public Integer getAgeDay() {
		return ageDay;
	}

	public void setAgeDay(Integer ageDay) {
		this.ageDay = ageDay;
	}


	public BigDecimal getMerks() {
		return merks;
	}

	public void setMerks(BigDecimal merks) {
		this.merks = merks;
	}
	

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getTwitter() {
		return twitter;
	}

	public void setTwitter(String twitter) {
		this.twitter = twitter;
	}

	public String getOrkut() {
		return orkut;
	}

	public void setOrkut(String orkut) {
		this.orkut = orkut;
	}

	public String getFacebook() {
		return facebook;
	}

	public void setFacebook(String facebook) {
		this.facebook = facebook;
	}

	public String getBlog() {
		return blog;
	}

	public void setBlog(String blog) {
		this.blog = blog;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getLogin() {
		return login;
	}

	public void setPassword2(String password2) {
		this.password2 = password2;
	}

	public String getPassword2() {
		return password2;
	}
	
	public boolean isPasswordEdited() {
		if  ((this.getPassword() == null) || (this.getPassword().trim().equals(""))) return false;
		return true;
	}

	public void setEmailValidToken(String emailValidToken) {
		this.emailValidToken = emailValidToken;
	}

	public String getEmailValidToken() {
		return emailValidToken;
	}
	
	public static String generateToken() {
		System.out.println(java.util.UUID.randomUUID().toString());

		return "1";
	}
	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public String getCountry() {
		return country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public boolean isUserInRole(String role) {
		
		return true;
	}
}
